package mylibrary.com.thinking.java.chapter15.s1523;

import java.util.*;

public class RandomList<T> {

	private List<T> storage = new ArrayList<T>();
	private Random rand = new Random(47);
	public void add(T item) {
		storage.add(item);
	}
	
	public T select() {
		return storage.get(rand.nextInt(storage.size()));
	}
	
	public static void main(String[] args) {
		//RandomList<String> rs = new RandomList<String>();
		RandomList rs = new RandomList();
		for(String s: "the quick brown fox".split(" ")) {
			rs.add(s);
		}
		for(int i=0; i<11; i++) {
			System.out.print(rs.select() + " ");
		}
		
		System.out.println();
		
		//RandomList<Integer> rs1 = new RandomList<Integer>();
		RandomList rs1 = new RandomList();
		for(int i=0; i<10; i++) {
			rs1.add(i);
		}
		for(int i=0; i<11; i++) {
			System.out.print(rs1.select() + " ");
		}
	}
}
